//#define simple

using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace TaskBooker.Controls.Panels
{
    public partial class ToDoItem : System.Windows.Controls.UserControl
    {
        public ToDoItem()
        {
            InitializeComponent();
        }

        private void UpdateBlock()
        {
            valueNumber.Content = Number;
            valueTitle.Text = Title;
            valueDescription.Content = Description;
        }
        //=============================================================================================================
        #region Properties
        #region NumberProperty
        public static DependencyProperty NumberProperty = DependencyProperty.Register( "Number", typeof( string ), typeof( ToDoItem ),
            new FrameworkPropertyMetadata( "", OnNumberChanged ) );

        [Category( "ToDoItemUserProperties" ), Description( "Gets or sets the Number." )]
        public string Number
        {
            get { return ( string )GetValue( NumberProperty ); }
            set { SetValue( NumberProperty, value ); }
        }

        private static void OnNumberChanged( DependencyObject source, DependencyPropertyChangedEventArgs e )
        {
            ToDoItem control = source as ToDoItem;
            string number = ( string )e.NewValue;
            control.Number = number;
            control.UpdateBlock();
        }
        #endregion
        #region TitleProperty
        public static DependencyProperty TitleProperty = DependencyProperty.Register( "Title", typeof( string ), typeof( ToDoItem ),
            new FrameworkPropertyMetadata( "", OnTitleChanged ) );

        [Category( "ToDoItemUserProperties" ), Description( "Gets or sets the Title." )]
        public string Title
        {
            get { return ( string )GetValue( TitleProperty ); }
            set { SetValue( TitleProperty, value ); }
        }

        private static void OnTitleChanged( DependencyObject source, DependencyPropertyChangedEventArgs e )
        {
            ToDoItem control = source as ToDoItem;
            string Title = ( string )e.NewValue;
            control.Title = Title;
            control.UpdateBlock();
        }
        #endregion
        #region DescriptionProperty
        public static DependencyProperty DescriptionProperty = DependencyProperty.Register( "Description", typeof( string ), typeof( ToDoItem ),
            new FrameworkPropertyMetadata( "", OnDescriptionChanged ) );

        [Category( "ToDoItemUserProperties" ), Description( "Gets or sets the Description." )]
        public string Description
        {
            get { return ( string )GetValue( DescriptionProperty ); }
            set { SetValue( DescriptionProperty, value ); }
        }

        private static void OnDescriptionChanged( DependencyObject source, DependencyPropertyChangedEventArgs e )
        {
            ToDoItem control = source as ToDoItem;
            string Description = ( string )e.NewValue;
            control.Description = Description;
            control.UpdateBlock();
        }
        #endregion
        #endregion

        //=============================================================================================================
        #region Events

        private void Border_MouseEnter( object sender, System.Windows.Input.MouseEventArgs e )
        {
            this.Background = Brushes.Bisque;
        }

        private void Border_MouseLeave( object sender, System.Windows.Input.MouseEventArgs e )
        {
            this.Background = Brushes.Transparent;
        }

        private void ValueTitle_MouseEnter( object sender, System.Windows.Input.MouseEventArgs e )
        {
            Control lbTitle = ( Control )sender;
            lbTitle.Background = Brushes.WhiteSmoke;
        }

        private void ValueTitle_MouseLeave( object sender, System.Windows.Input.MouseEventArgs e )
        {
            Control lbTitle = ( Control )sender;
            lbTitle.Background = Brushes.Transparent;
        }

        private void UserControl_Loaded( object sender, RoutedEventArgs e )
        {

        }

        #endregion
    }
}